﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace ProjetPlatformer.gameElements
{
    public class GameElement : DrawableGameComponent, IFocusable
    {


        protected SpriteBatch spriteBatch;
        protected ContentManager contentManager;
        public Vector2 position;
        protected Vector2 size;
        public Rectangle bBox;
        public bool isColliding = false;
        public bool isOnground = false;
        

        public GameElement(Game game, SpriteBatch sb, ContentManager cm) : base(game)
        {
            position = new Vector2(300, 300);
            size = new Vector2(64, 64);
            spriteBatch = sb;
            contentManager = cm;
            bBox = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
        }

        public GameElement(Game game, SpriteBatch sb, ContentManager cm, int decalageX, int decalageY) : this (game,sb,cm)
        {
                position.X += decalageX;
                position.Y += decalageY;
                bBox = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
            

        }

        public Vector2 getPosition()
        {
            return new Vector2(position.X, position.Y);
        }

        public void setPosition(Vector2 newPosition)
        {
            if (newPosition != null)
            {
                position.X = newPosition.X;
                position.Y = newPosition.Y;
                bBox.X = (int)newPosition.X;
                bBox.Y = (int)newPosition.Y;
            }

        }

        public void applyMotionVector(Vector2 motion)
        {
            this.setPosition(this.position + motion);
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
        }


    }
}
